package com.lulu.landslidedemo04;

import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.lulu.landslidedemo04.model.TestModel;

/**
 * Created by zhanglulu on 2017/3/28.
 * 这是案例
 */

public class LandSlideAdapter extends BaseLandSlideAdapter<TestModel> {

    public LandSlideAdapter(Context context) {
        super(context);
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        if (convertView == null) {
            convertView = LayoutInflater.from(mContext).inflate(R.layout.bookshelf_list_item, parent, false);
            convertView.setTag(new ViewHolder(convertView));
        }
        ViewHolder holder = (ViewHolder) convertView.getTag();
        holder.bindData(mList.get(getRealPosition(position)));
        return convertView;
    }

    @Override
    public TestModel getItem(int position) {
        return mList.get(getRealPosition(position));
    }

    static class ViewHolder {
        TextView text;

        public ViewHolder(View itemView) {
            text = ((TextView) itemView.findViewById(R.id.bookshelf_bookname));
        }
        public void bindData(TestModel model) {
            text.setText(model.text);
        }

    }
}
